package giaodien;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Label;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTextField;


import com.l2fprod.common.swing.JTaskPane;
import com.l2fprod.common.swing.JTaskPaneGroup;

public class DangNhap extends JFrame{
	Toolkit toolkit;
	Dimension sreensize;
	public MyButton btnDangNhap=new MyButton("Đồng ý");
	public MyButton btnHuy=new MyButton("Hủy");
	JLabel lb1=new JLabel("Tài khoản");
	JLabel lb2=new JLabel("Mật khẩu ");
	JLabel lb3=new JLabel(new ImageIcon("image/login.jpg"));
	JLabel lb4=new JLabel("Tên cơ sở dữ liệu");
	JLabel lb5=new JLabel("Tài khoản dữ liệu");
	JLabel lb6=new JLabel("Mật khẩu dữ liệu ");
	JTextField txt1=new JTextField();
	String[] list=new String[2];
	JComboBox<String> cxt1;
	JComboBox<String> cxt2;
	JPasswordField pxt1=new JPasswordField();
	JPasswordField pxt2=new JPasswordField(20);
	JCheckBox chexbox=new JCheckBox("Ghi nhớ tài khoản");
	JTaskPane task;
	public DangNhap(GiaoDien giaodien) {
		super("Đăng Nhập");
		toolkit=Toolkit.getDefaultToolkit();
		sreensize=toolkit.getScreenSize();
		this.setLocationRelativeTo(null);
		this.setSize(400, 300);
		this.setResizable(false);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage("image/agt-login-icon.png"));
		list[0]="orcl";
		list[1]="oracle";
		cxt1=new JComboBox<String>(list);
		cxt2=new JComboBox<String>(list);
		CreateLayout();
	}
	public void CreateLayout(){
		lb1.setForeground(Color.BLUE);
		lb2.setForeground(Color.BLUE);
		lb3.setForeground(Color.BLUE);
		lb4.setForeground(Color.BLUE);
		lb5.setForeground(Color.BLUE);
		lb6.setForeground(Color.BLUE);
		
		chexbox.setForeground(Color.BLUE);
		btnDangNhap.setForeground(Color.BLUE);
		btnHuy.setForeground(Color.BLUE);
		lb1.setHorizontalAlignment(JLabel.RIGHT);
		
		JPanel pn2=new JPanel();
		pn2.setLayout(null);
		pn2.add(lb1);
		pn2.add(txt1);
		Insets inset=pn2.getInsets();
		Dimension size=lb1.getPreferredSize();
		lb1.setBounds(25+inset.left, 7+inset.top, size.width, size.height);
		txt1.setBounds(95+inset.left,7+inset.top, size.width+200,10+ size.height);
		
		JPanel pn3=new JPanel();
		pn3.setLayout(null);
		pn3.add(lb2);
		pn3.add(pxt1);
		Insets inset2=pn3.getInsets();
		Dimension size2=lb2.getPreferredSize();
		lb2.setBounds(25+inset2.left,10+inset2.top, size2.width, size2.height);
		pxt1.setBounds(95+inset2.left,5+inset2.top, size2.width+200, 10+size2.height);
		
		JPanel pn4=new JPanel(new GridLayout(1, 4, 5, 5));
		pn4.add(new Label());
		pn4.add(new Label());
		pn4.add(btnDangNhap);
		pn4.add(btnHuy);
		
		task=taskSpan();
		JPanel pn5=new JPanel(new BorderLayout(5,5));
		pn5.add(pn4,BorderLayout.CENTER);
		pn5.add(task,BorderLayout.SOUTH);
		
		
		lb3.setHorizontalAlignment(JLabel.CENTER);
		JPanel pn7=new JPanel();
		pn7.setLayout(null);
		pn7.add(chexbox);
		Insets inset4=pn7.getInsets();
		chexbox.setBounds(91+inset4.left, 10+inset4.top, size.width+100, size.height);
		JPanel pn8=new JPanel(new GridLayout(3,1));
		pn8.add(pn2);
		pn8.add(pn3);
		pn8.add(pn7);

		JPanel pn1=new JPanel(new GridLayout(2,1));
		pn1.add(lb3);
		pn1.add(pn8);
		
		JPanel pn6=new JPanel(new BorderLayout(5,5));
		pn6.add(pn1,BorderLayout.CENTER);
		pn6.add(pn5,BorderLayout.SOUTH);
		this.add(pn6);
	}	
	JTaskPaneGroup group;
	public JTaskPane taskSpan(){
		JTaskPane taskpan=new JTaskPane();
		 group=new JTaskPaneGroup();
		group.setTitle("Cơ sở dữ liệu");
		group.setIcon(new ImageIcon("image/arrow_down_mini.png"));
		group.setSpecial(true);
		JPanel pn5=new JPanel(new BorderLayout(11,15));
		pn5.add(lb4,BorderLayout.WEST);
		cxt1.setEditable(true);
		cxt2.setEditable(true);
		pxt2.setPreferredSize(new Dimension(120,25));
		pn5.add(cxt1,BorderLayout.CENTER);
		
		JPanel pn6=new JPanel(new BorderLayout(15,15));
		pn6.add(lb5,BorderLayout.WEST);
		pn6.add(cxt2,BorderLayout.CENTER);
		
		JPanel pn7=new JPanel(new GridBagLayout());
		GridBagConstraints c=new GridBagConstraints();
		c.fill=GridBagConstraints.HORIZONTAL;
		c.gridx=c.gridy=0;
		c.gridheight=c.gridwidth=1;
		c.weightx=c.weighty=0.0;
		pn7.add(lb6,c);
		c.insets=new Insets(0, 15, 0, 0);
		c.gridx=1;c.gridy=0;
		c.gridheight=c.gridwidth=4;
		c.weightx=c.weighty=1.5;
		pn7.add(pxt2,c);
		
		
		group.add(pn5);
		group.add(pn6);
		group.add(pn7);
		group.setScrollOnExpand(true);
		group.setExpanded(false);
		taskpan.add(group);
		JScrollPane srollpane=new JScrollPane();
		srollpane.setBorder(null);
		taskpan.setBorder(null);
		group.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent arg0) {
				
			}
			
			@Override
			public void mousePressed(MouseEvent arg0) {
				setSize(400, 380);
				group.setIcon(new ImageIcon("image/arrow_right_mini.png"));
			}
			
			@Override
			public void mouseExited(MouseEvent arg0) {
				
			}
			
			@Override
			public void mouseEntered(MouseEvent arg0) {
				
			}
			
			@Override
			public void mouseClicked(MouseEvent arg0) {
				setSize(400, 300);	
				group.setIcon(new ImageIcon("image/arrow_down_mini.png"));
			}
		});
		return taskpan;
	}
}
